#!/dis/sh
if {~ $1 '@*'} {
	user = $1
	msg = `{webgrab -r http://twitter.com/$user >[2=1]}
	html = `{echo $msg | sed 's,^[^ ]+ ,,;s/,.*$//'}
	grep entry-content $html | sed -f /lib/sed/dehtml | sed 's,^[ 	]*,,;s,$,\n,' | fmt -w 63
	rm -f $html
} {
	query = $*
	urlenc = `{echo $query | sed 's, ,+,g;s,#,%23,g;s,'',%27,g'}
	url = 'http://search.twitter.com/search?q=%22'^$urlenc^'%22'
	message = `{webgrab -r $url >[2=1]}
	html = `{echo $message | sed 's,^[^ ]+ ,,;s/,.*$//'}
	grep -v '<!-- Fetched' $html | sed -f /lib/sed/dehtml | sed 's,^[	 ]+,,' | sed -n '/^[^: ]+: /,/ ago$/p' | sed 's,^(about )?[0-9]+ (seconds?|minutes?|hours?|days?) ago$,,' | fmt -w 62
	rm -f $html
}
